<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function myCurried(fn) {
            return function curry(...args1) {
                if (args1.length >= fn.length) {
                    return fn.call(null, ...args1)
                } else {
                    return function (...args2) {
                        return curry.apply(null, [...args1, ...args2])
                    }
                }
            }
        }

        function sum(a, b, c, d, e) {
            return a + b + c + d + e
        }
        let resFunc = myCurried(sum)
        console.log(resFunc(1, 3, 4)(1)(23))
            //解析:
            //1、这里的fn.length获取的是函数传入参数的长度
            //2、这里使用递归
    </script>
</body>

</html>